package cn.azzhu.day06

import java.util.Properties

import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala._
import org.apache.flink.streaming.connectors.kafka.{FlinkKafkaConsumer, FlinkKafkaProducer}

/**
 * @author azzhu
 * @create 2020-09-21 23:42:58
 */
object FlinkReadFromKafka {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)

    val props = new Properties()
    props.put("bootstrap.servers","hadoop105:9092")
    props.put("group.id","consumer-group")
    props.put("key.deserializer","org.apache.kafka.common.serialization.StringDeserializer")
    props.put("value.deserializer","org.apache.kafka.common.serialization.StringDeserializer")
    props.put("auto.offset.reset","latest")

    val stream = env.addSource(new FlinkKafkaConsumer[String]("test", new SimpleStringSchema(), props))

    stream.print()

    env.execute("FlinkWriteToKafka")
  }
}
